package com.test.controller;

import com.test.dto.ResultBean;
import com.test.entity.UserEntity;
import com.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 控制器类
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(path = "/listAll")
    @ResponseBody
    public ResultBean listAll(){

        List<UserEntity> userEntities = userService.listAllUser();

        /**
         * 配置好视图解析器，如果返回success字符串，就会到相应的配置中的目录查找与success同名的jsp页面作为结果返回请求
         */
        return ResultBean.ok(userEntities);
    }
}
